package com.chat.controller;

import com.chat.domain.dto.chat.ChatQueryDTO;
import com.chat.service.ChatService;
import com.chat.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 聊天控制器
 *
 * @author wb
 * @since 2024-09-13
 */

@RestController
@RequestMapping("chat")
public class ChatController {

    @Autowired
    private ChatService chatService;

    @GetMapping("/list")
    public Result<Object> chats(ChatQueryDTO chatQueryDTO) {
        return Result.ok(chatService.getChats(chatQueryDTO));
    }


    @GetMapping("/clean/{chatId}")
    public Result<Object> clean(@PathVariable("chatId") String chatId) {
        return chatService.clean(chatId) ? Result.ok() : Result.fail();
    }

}
